<?php

class TreeView_Model extends MyModel
{
    function __construct()
    {
        parent::__construct();
    }
    
    function getAllTinhThanh()
    {
        $str = "SELECT matinhthanh, tentinhthanh 
                FROM tinhthanh";
                
        $query = mysql_query($str);
        return $query;        
    }
    
    function getQuanHuyen($maTinhThanh)
    {
        $str = "SELECT maquanhuyen, tenquanhuyen 
                FROM quanhuyen 
                WHERE matinhthanh = '{$maTinhThanh}'";
                
        $query = mysql_query($str);
        return $query;
    }
    
    function getPhuongXa($maQuanHuyen)
    {
        $str = "SELECT maphuongxa, tenphuongxa 
                FROM phuongxa 
                WHERE maquanhuyen = '{$maQuanHuyen}'";
                
        $query = mysql_query($str);
        return $query;
    }
    
    function getThonXom($maPhuongXa)
    {
        $str = "SELECT mathonxom, tenthonxom 
                FROM thonxom 
                WHERE maphuongxa = '{$maPhuongXa}'";
                
        $query = mysql_query($str);
        return $query;
    }   
    
    public function treeview()
    {
        $rows = $this->model->getAllTinhThanh();
        include("View/header.php");
        include("View/tinhthanh/treeview.php");
        include("View/footer.php");
    }
}

?>